<template>
  <common-card title="今日销售额" :value="numberFormat(salesToday)">
    <div class="compare-wrap">
      <div class="compare">
        <div>日同比</div>
        <div class="number">{{ salesGrowthLastDay }}%</div>
        <div :class="(salesGrowthLastDay as number)>0?'increment':'decrement'"></div>
      </div>
      <div class="compare">
        <div>月同比</div>
        <div class="number">{{ salesGrowthLastMonth }}%</div>
        <div :class="(salesGrowthLastMonth as number)>0?'increment':'decrement'"></div>
      </div>
    </div>
    <template v-slot:bottom>
      <span>昨日销售额</span><span class="number">{{ moneyFormat(salesLastDay) }}</span>
    </template>
  </common-card>
</template>
<script lang="ts">
export default {
  name: "TodaySales",
};
</script>
<script lang="ts" setup>
// 引入可视化数据的仓库
import { useDataStore } from "../../../stores/reportData";
import { computed } from "vue";
import useFormat from "../../../hooks/useFormat";
const dataStore = useDataStore();
const { numberFormat, moneyFormat } = useFormat();

// 做计算属性的数据
const salesToday = computed(() => {
  return dataStore.reportData.salesToday as number;
});
const salesLastDay = computed(() => {
  return dataStore.reportData.salesLastDay as number;
});
const salesGrowthLastDay = computed(() => {
  return dataStore.reportData.salesGrowthLastDay as number;
});
const salesGrowthLastMonth = computed(() => {
  return dataStore.reportData.salesGrowthLastMonth as number;
});
</script>
<style lang="scss" scoped>
.compare-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  color: #666;
  font-weight: 600;
  font-size: 12px;
  .compare {
    display: flex;
    flex: 1;
    align-items: center;
  }
}
</style>
